//
//  MPSearchView.m
//  QAPro
//
//  Created by Hyukooooh on 2024/5/6.
//

#import "MPSearchView.h"

@interface MPSearchView()
@property (nonatomic, strong) UILabel *tipsLb;
@property (nonatomic, strong) UIView *containerView;

@end
@implementation MPSearchView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self layoutUI];
    }
    return self;
}

- (void)tapAction{
    if(_searchClick){
        _searchClick();
    }
}

- (void)layoutUI{
    UIView *containerView = [UIView new];
    self.containerView = containerView;
    containerView.backgroundColor = [UIColor assist_Space_Color];
    [self addSubview:containerView];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
    [containerView addGestureRecognizer:tap];
    ViewRadius(containerView, 4);
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(16);
        make.right.offset(-16);
        make.height.mas_equalTo(36);
    }];
    UIImageView *imgV = [UIImageView new];
    imgV.image = [UIImage imageNamed:@"search_icon_search"];
    [containerView addSubview:imgV];
    [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(28, 28));
        make.left.offset(12);
        make.centerY.equalTo(containerView);
    }];
    
    UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    tipLabel.text = @"搜索";
    tipLabel.font = WCIFontRegular(14);
    tipLabel.textColor = [UIColor assist_ClickText_color];
    self.tipsLb = tipLabel;
    [containerView addSubview:tipLabel];
    [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(containerView);
        make.left.equalTo(imgV.mas_right).offset(7);
    }];
}


- (void)setSearchTips:(NSString *)searchTips{
    _searchTips = searchTips;
    self.tipsLb.text = searchTips;
}
@end
